﻿using ConfExpert.Forms.Base;
using DevExpress.XtraEditors.Repository;
using Extensions;
using System;
using System.Data;

namespace ConfExpert.Forms.Raporlar
{
    public partial class AzMetrajliStok : XForm
    {
        public AzMetrajliStok()
        {
            InitializeComponent();
        }

        private void AzMetrajliStok_Load(object sender, EventArgs e)
        {
            

            Rfrsh();

            gleCustomer.EditValueChanged += gleCustomer_EditValueChanged;
            btnGetir.ItemClick += btnGetir_ItemClick;
        }

        void gleCustomer_EditValueChanged(object sender, EventArgs e)
        {
            btnGetir.Enabled = false;
            Rfrsh();
            btnGetir.Enabled = true;
        }

        void btnGetir_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Rfrsh();
        }

        void Rfrsh()
        {
            DataSet d = ExecuteDataSet("GetAzMetrajliStok", txtMax.EditValue.ToDecimal(), gleCustomer.EditValue.ToInt());

            gridView1.Init(d.Tables[0]);
            RepositoryItemGridLookUpEdit ri = GetCustomGLE(d.Tables[1], "Customer", "CustomerId");
            ri.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gleCustomer.Edit.Assign(ri);

            gridView1.MakeReadOnly();
            gridView1.FormatAsNumber(1, "Qty");
            gridView1.AddSummary("Qty");
            gridView1.BestFitColumns();
        }

    }
}
